/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} head
 * @return {boolean}
 */
 var hasCycle = function(head) {
    if(!head || !head.next) 
        return null

    let slow = head ,fast = head
    while(slow != null&&fast.next != null&&fast.next.next!=null){
        slow = slow.next
        fast = fast.next.next

        if(slow == fast){
            return true
        }
    }

    return false
};